package com.example.curd.controller;


import com.example.curd.entity.Good;
import com.example.curd.entity.Role;
import com.example.curd.service.IGoodService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dakai
 * @since 2021-04-18
 */
@RestController
@RequestMapping("/good")
public class GoodController {

  @Autowired
  IGoodService iGoodService;

  @ApiOperation("查询全部商品")
  @GetMapping("/selectAllGood")
  List<Good> SelectAll(){
    return iGoodService.selectAllGood();
  }

  @ApiOperation("查询商品")
  @GetMapping("/getGoodById")
  Good getGoodById(Integer gid){
    return iGoodService.getGoodById(gid);
  }

  @ApiOperation("删除商品")
  @DeleteMapping("/deleteGood")
  void deleteGood(Integer gid){
    iGoodService.deleteGood(gid);
  }

  @ApiOperation("添加商品")
  @PostMapping("/addGood")
  void addGood(Good good){
    iGoodService.addGood(good);
  }

  @ApiOperation("更新商品")
  @PutMapping("/updateGood")
  void updateGood(Good good){
    iGoodService.updateGood(good);
  }
}
